package com.zmn.mcc.admin.controller.role.permit;

import com.zmn.common.constant.GlobalConsts;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.common.utils.request.RequestUtil;
import com.zmn.common.utils.string.StringUtil;
import com.zmn.mcc.model.entity.role.McRolePermit;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author heguanghua
 * @since 2020/04/15 10:50
 */
@Controller
@RequestMapping("/role/permit/modify/")
public class RolePermitModifyController extends RolePermitBaseController {


    /**
     * 为角色分配功能权限
     */
    @RequestMapping("assign")
    @ResponseBody
    public ResponseDTO assign(HttpServletRequest request, HttpServletResponse response,
                              @RequestParam(value = "roleId", defaultValue = "0") Integer roleId,
                              @RequestParam(value = "permitIds", defaultValue = "") String permitIds) {

        ResponseDTO result = roleBService.assignPermitBatch(roleId, StringUtil.split(permitIds, Integer.class), getStaffId(), RequestUtil.getRequestIp(request));
        return result;
    }
}
